package io.gitee.zhangbinhub.acp.cloud

import io.gitee.zhangbinhub.acp.boot.log.LogAdapter
import io.gitee.zhangbinhub.acp.cloud.lock.DistributedLock
import io.gitee.zhangbinhub.acp.cloud.lock.RedisDistributedLock
import org.redisson.api.RedissonClient
import org.springframework.boot.autoconfigure.AutoConfiguration
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.context.annotation.Bean

@AutoConfiguration(after = [AcpCloudLogAutoConfiguration::class])
class AcpCloudDistributedLockAutoConfiguration {
    @Bean
    @ConditionalOnMissingBean(DistributedLock::class)
    fun redisDistributedLock(logAdapter: LogAdapter, redissonClient: RedissonClient): DistributedLock =
        RedisDistributedLock(logAdapter, redissonClient)
}